package com.gopay.common.event.store;

import java.util.Collection;
import java.util.concurrent.Callable;

import com.gopay.common.datasource.DBType;
import com.gopay.common.datasource.DbContextHolder;
import com.gopay.common.domain.report.Event;
import com.gopay.common.domain.report.MqEventTimeoutLog;
import com.gopay.common.report.dao.MqEventTimeoutLogDAO;

/**
 * @EventStoreTimeoutTask.java
 * @author fanghw
 * @2015年7月8日 下午2:37:57  www.gopay.com.cn Inc.All rights reserved.
 */
public class EventStoreTimeoutTask  implements Callable<Boolean> {
    private Collection<Event> eventList;
    private MqEventTimeoutLogDAO mqEventTimeoutLogDAO;

    public EventStoreTimeoutTask(Collection<Event> eventList, MqEventTimeoutLogDAO mqEventTimeoutLogDAO) {
        this.eventList = eventList;
        this.mqEventTimeoutLogDAO = mqEventTimeoutLogDAO;
    }

    @Override
    public Boolean call() throws Exception {        
        MqEventTimeoutLog log;
        for (Event event : eventList) {
            log=new MqEventTimeoutLog();
            log.setType(event.getType());
            log.setSnapshot(event.getSnapshot());
            log.setStat(event.getStat());
            log.setGopayOrderId(event.getGopayOrderId());
            log.setBatchTaskId(event.getBatchTaskId());
            log.setRemark1(event.getRemark1());
            log.setRemark2(event.getRemark2());
            log.setCreatedTs(event.getCreatedTs());
            log.setLastUpdTs(event.getLastUpdTs());

            mqEventTimeoutLogDAO.save(log);
        }

        return true;
    }

}

